package com.tuzhi.sys.dto;

import lombok.Data;
import org.apache.commons.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Data
public class SysDicTreeDto {
    /**
     * 类别编码
     */
    private String categoryCode;
    /**
     * 类别名称
     */
    private String categoryName;
    /**
     * 上级类别编码
     */
    private String categoryParent;
    /**
     * 项目编码
     */
    private String itemCode;
    /**
     * 项目名称
     */
    private String itemName;


    private String itemDesc;

    /**
     * 子类别
     */
    private List<SysDicTreeDto> subCategoryList;

    public SysDicTreeDto(String categoryCode, String categoryName, String categoryParent, String itemCode, String itemName, String itemDesc) {
        this.categoryCode = categoryCode;
        this.categoryName = categoryName;
        this.categoryParent = categoryParent;
        this.itemCode = itemCode;
        this.itemName = itemName;
        this.itemDesc = itemDesc;
    }

    public void addSub(SysDicTreeDto sysDicTreeDto) {
        if (CollectionUtils.isEmpty(subCategoryList)) {
            subCategoryList = new ArrayList<>();
        }
        subCategoryList.add(sysDicTreeDto);
    }
}
